<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 800px;
            height: 20px;
            border-radius: 4px;
            margin: 100px auto;
            border: 2px solid green;
            position: relative;
        }

        #jinDuTiao {
            height: 20px;
            background: orange;
            border-radius: 4px;
            float: left;
        }

        #num {
            position: absolute;
            transform: translateY(-50%);
            top: 50%;
            left: 5px;
        }
    </style>
</head>
<body>
    <div class="box">
        <div id="jinDuTiao" style="width: 0px;"></div>
        <span id="num">0%</span>
    </div>
    <script>
        // 进度条 需用通过定时器 去改变 进度条宽度  在js中需要实现动画，就必须使用定时器
        var i = 0
        setInterval(function(){
           
            i += 2
            if(i >= 800){
                i = 800
            }
            jinDuTiao.style.width = i + 'px'
            num.style.left = i + 4 + 'px'
            num.innerHTML = ((i / 800) * 100).toFixed(2) + '%'
        },100)
    </script>
</body>
</html>